package me.yricky.hid.desktop

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Icon
import androidx.compose.material.LocalContentAlpha
import androidx.compose.material.LocalContentColor
import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

object Theme {
    object Icons{
        @Composable
        fun alignBottom() = painterResource("icons/semi-icons-align_bottom.svg")
        @Composable
        fun bluetooth() = painterResource("icons/ioni-bluetooth-outline.svg")
        @Composable
        fun browse() = painterResource("icons/semi-icons-folder_open.svg")
        @Composable
        fun close() = painterResource("icons/semi-icons-close.svg")
        @Composable
        fun clock() = painterResource("icons/semi-icons-clock.svg")
        @Composable
        fun delete() = painterResource("icons/semi-icons-delete.svg")
        @Composable
        fun expand() = painterResource("icons/semi-icons-full_screen_stroked.svg")
        @Composable
        fun home() = painterResource("icons/semi-icons-home.svg")
        @Composable
        fun i2c() = painterResource("icons/arrows-v-alt.svg")
        @Composable
        fun refresh() = painterResource("icons/semi-icons-refresh.svg")
        @Composable
        fun receive() = painterResource("icons/semi-icons-arrow_down_right.svg")
        @Composable
        fun send() = painterResource("icons/semi-icons-arrow_up_right.svg")
        @Composable
        fun sendAction() = painterResource("icons/semi-icons-send_stroked.svg")
        @Composable
        fun setting() = painterResource("icons/semi-icons-setting.svg")
        @Composable
        fun shrink() = painterResource("icons/semi-icons-shrink_screen_stroked.svg")
        @Composable
        fun spi() = painterResource("icons/swap-vertical.svg")
        @Composable
        fun terminal() = painterResource("icons/semi-icons-terminal.svg")
        @Composable
        fun unknown() = painterResource("icons/semi-icons-help_circle.svg")
        @Composable
        fun usb() = painterResource("icons/cssgg-usb.svg")

    }
}

@Composable
fun IconButton(
    size:Dp,
    painter: Painter,
    tint: Color? = null,
    contentDescription: String? = null,
    onClick:()->Unit,
){
    Surface(
        modifier = Modifier.size(size),
        color = Color.Transparent,
        shape = RoundedCornerShape(size)
    ) {
        Icon(
            painter = painter,
            contentDescription = contentDescription,
            tint = tint ?: LocalContentColor.current.copy(alpha = LocalContentAlpha.current),
            modifier = Modifier
                .clickable {
                    onClick()
                }
                .fillMaxSize()
                .padding(4.dp)
        )
    }
}